package com.devicemantra.coordinate.dataobjects;

import javax.jdo.annotations.*;


import java.util.*;

import com.google.appengine.api.datastore.Key;
import com.google.appengine.api.datastore.KeyFactory;

@PersistenceCapable(identityType = IdentityType.APPLICATION, detachable ="true")
public class CMessage1 
{
	@PrimaryKey
    @Persistent (valueStrategy = IdGeneratorStrategy.IDENTITY)
    private Key mMessageKey;
	
	@Persistent
	private String mMessage;
	
	@Persistent
	private String mDestinationLocationId;
	
	@Persistent(defaultFetchGroup="true")
	private Date mReceivedDate;
	
	private boolean mIsRead = false;
	
	public CMessage1()
	{
		
	}
	
	public CMessage1(String pMessage)
	{
		mMessage = pMessage;
	}
	
	
	public CMessage1(String pMessage, Date pReceivedDate, String pFrameId)
	{
		mMessage = pMessage;
		mReceivedDate = pReceivedDate;
		mDestinationLocationId = pFrameId;
		
	}
	
	public void setLocationId(String pLocationId)
	{
		mDestinationLocationId = pLocationId;
	}
	
	public void setDate(Date pDate)
	{
		mReceivedDate = pDate;
	}
	
	public void setMessage(String pMessage)
	{
		mMessage = pMessage;
	}
	
	public String getMessage()
	{
		return mMessage;
	}
	
	public Date getDate()
	{
		return mReceivedDate;
	}
	
	public String getLocationId()
	{
		return mDestinationLocationId;
	}
	
	public void markAsRead()
	{
		mIsRead = true;
	}
	
	public void markAsUnRead()
	{
		mIsRead = false;
	}
	
	public String getMessageId()
	{
		return KeyFactory.keyToString(mMessageKey);
	}
	
}
